<?php
/**
 * Booking Model for Room Booking Component
 * 
 * @version 1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license		GNU/GPL
 */

 
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.model' );
 
class RoomBookingModelStatistics extends JModel
{
    /**
	 * Constructor that retrieves the ID from the request
	 *
	 * @access	public
	 * @return	void
	 */
	function __construct()
	{
		parent::__construct();

		$array = JRequest::getVar('cid',  0, '', 'array');
		$this->setId((int)$array[0]);
	}

	/**
	 * Method to set the identifier
	 *
	 * @access	public
	 * @param	int identifier
	 * @return	void
	 */
	function setId($id)
	{
		// Set id and wipe data
		$this->_id		= $id;
		$this->_data	= null;
	}

	/**
	 * Method to get a booking record
	 * @return object with data
	 */
	function &getData()
	{
		// Load the data
                $user =& JFactory::getUser();
		if (empty( $this->_data )) {
			$query = ' SELECT * FROM jos_roombooking_bookings '.
					'  WHERE id_user = '.$user->get('id').'  ORDER BY end DESC';
                        $this->_data = $this->_getList( $query );
		}
		return $this->_data;
	}
	
}
